from django.db import models
from apps.common.base.models import BaseModel
from apps.system.router.models import Router
from apps.system.lessee.models import Lessee


class Role(BaseModel):
    key = models.CharField("角色关键字", max_length=100, unique=True, default='custom')
    name = models.CharField("名称", max_length=200, blank=True, default='')

    routers = models.ManyToManyField(Router, related_name='routers_role', blank=True, default=[], db_constraint=False)
    lessee = models.ForeignKey(Lessee, related_name="lessee_role", verbose_name='租户',
                               on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    class Meta:
        verbose_name = '角色'
        verbose_name_plural = verbose_name
